<?php
require_once ("../src/db/connectdatabase.php");

function getIntroLoan($idloan) {
	$con = new ConnectDB();
	$tbl = "loans";
	$fn = array('content_loan', 'condition_loan');
	$condetion = array('loan_id' => $idloan);
	return $con -> getvalue($tbl, $fn, $condetion);
}

if(isset($_GET['as'])) {
	$idloan = $_GET['as'];
	if($idloan == "vay_the_chap" || $idloan == "vay_tra_gop" || $idloan == "vay_ca_nhan") {
		$stringloan = "";
		if($idloan == "vay_the_chap") {
			$stringloan = "Vay Thế Chấp";
		} else if($idloan == "vay_tra_gop") {
			$stringloan = "Vay Trả Góp";
		} else if($idloan == "vay_ca_nhan") {
			$stringloan = "Vay Cá Nhân";
		}
		
		$introloan = getIntroLoan($idloan);
		if(count($introloan) == 1) {
?>
<style>
textarea {
	margin:5px;
	padding:5px;
}
</style>
<h3>Cập Nhật Thông Tin Giới Thiệu <?php echo($stringloan) ?></h3>
<div style="color: red;">
<?php
	if(isset($_GET['mess'])) {
		echo($_GET['mess']);
	}
?>
</div>
<div style="width: 850px;">
	<form action="../src/control/adminintroducerate.php" method="post">
        <table>
            <tr>
            	<td valign="top"><div style="clear:both; margin-top: 10px; border: 1px solid; padding: 5px; background: #61C799; border-radius: 5px; color:#FFF">Giới thiệu đầu trang</div></td>
                </tr>
                <tr>
                <td>
                	<textarea id="textfieldcontentheader" name="textfieldcontentheader" rows="30" cols="200" style="width: 880px; max-width:880px; min-width:880px;" class="tinymce"><?php echo($introloan[0][1]) ?></textarea>
                </td>
            </tr>
            <tr>
            	<td valign="top"><div style="clear:both; margin-top: 10px; border: 1px solid; padding: 5px; background: #61C799; border-radius: 5px; color:#FFF">Giới thiệu cuối trang</div></td>
                </tr>
                <tr>
                <td>
                	<textarea id="textfieldcontent" name="textfieldcontent" rows="30" cols="200" style="width: 880px; max-width:880px; min-width:880px;" class="tinymce"><?php echo($introloan[0][0]) ?></textarea><input type="hidden" value="<?php echo($idloan) ?>" name="id" />
                </td>
            </tr>
            <tr>
            	<th colspan="2"><input type="hidden" name="acc" value="edit" /><input type="submit" value="Cập Nhật" style="border-radius: 5px; padding:5px; width:100px; background:#03F; color:#FFF; font-weight:bold;" /></th>
            </tr>
        </table>
    </form>
</div>
<?php
		}
	}
}
?>